package com.wdc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wdc.mapper.FollowMapper;
import com.wdc.model.domain.Follow;
import com.wdc.model.domain.User;
import com.wdc.model.vo.UserVO;
import com.wdc.service.FollowService;
import com.wdc.service.UserService;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow>
        implements FollowService {

    @Resource
    @Lazy
    private UserService userService;

    @Override
    public void followUser(Long followUserId, Long userId) {
        LambdaQueryWrapper<Follow> followLambdaQueryWrapper = new LambdaQueryWrapper<>();
        followLambdaQueryWrapper.eq(Follow::getFollowUserId,followUserId).eq(Follow::getUserId,userId);
        long count = this.count(followLambdaQueryWrapper);
        if (count == 0){
            Follow follow = new Follow();
            follow.setFollowUserId(followUserId);
            follow.setUserId(userId);
            this.save(follow);
        }else {
            this.remove(followLambdaQueryWrapper);
        }
    }

    @Override
    public List<UserVO> listFans(Long userId) {
        return List.of();
    }

    @Override
    public List<UserVO> listMyFollow(Long userId) {
        return List.of();
    }

    @Override
    public Page<UserVO> pageMyFollow(Long userId, String currentPage) {
        return null;
    }

    @Override
    public Page<UserVO> pageFans(Long userId, String currentPage) {
        return null;
    }

    @Override
    public UserVO getUserFollowInfo(User user, long userId) {
        return null;
    }
}
